package com.mz.mattress.client.api.biz;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mz.mattress.api.common.Result;
import com.mz.mattress.api.entity.OrderUseTimesBonus;
import com.mz.mattress.api.jwt.ClientJwt;
import com.mz.mattress.client.api.req.OrderUseRecordBonusQueryReq;
import com.mz.mattress.client.common.Holder;
import com.mz.mattress.client.service.OrderUseTimesBonusService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("orderUseTimesBonus")
public class OrderUseTimesBonusController {

    @Autowired
    private OrderUseTimesBonusService orderUseTimesBonusService;

    @GetMapping("/listPage")
    public Result<IPage<OrderUseTimesBonus>> listPage(OrderUseRecordBonusQueryReq req) {

        ClientJwt clientJwt = Holder.CLIENT_JWT_THREAD_LOCAL.get();
        req.setMemberId(clientJwt.getMemberId());

        return orderUseTimesBonusService.listPage(req);
    }

    @GetMapping(value = "/{id}")
    public Result<OrderUseTimesBonus> detail(@PathVariable Integer id) {
        return orderUseTimesBonusService.getById(id);
    }

}
